
/**
 * 树图标映射
 */
export const iconMap = {
  'folder': 'icon-folder',
  'folderall': 'icon-quanbu',
  'foldern': 'icon-folder',
  'folderw': 'icon-duxie',
  'foldert': 'icon-gongxiangduxie',
  'folderr': 'icon-zhidu',
  'folderv': 'icon-gongxiangzhidu',
  'dl': 'icon-layers',
  'ods': 'icon-layers',
  'dwd': 'icon-layers',
  'dim': 'icon-layers',
  'dws': 'icon-layers',
  'tdm': 'icon-layers',
  'ads': 'icon-layers',
  'table': 'icon-table',
  'dataset': 'icon-table',
  'clickhouse': 'icon-shujuyuan',
  'hbase': 'icon-shujuyuan',
  'mysql': 'icon-shujuyuan',
  'oracle': 'icon-shujuyuan',
  'hive': 'icon-shujuyuan',
  'file': 'icon-shujuyuan',
  'sftp': 'icon-shujuyuan',
  'db2': 'icon-shujuyuan',
  'sqlserver': 'icon-shujuyuan',
  'spark': 'icon-shujuyuan',
  'postgresql': 'icon-shujuyuan',
  'trafodion': 'icon-shujuyuan',
  'impala': 'icon-shujuyuan',
  'data-std': 'icon-shujuyuan',
  'hana': 'icon-shujuyuan',
  'dameng': 'icon-shujuyuan',
  'kingbase': 'icon-shujuyuan',
  'gbase': 'icon-shujuyuan',
  'kylin': 'icon-shujuyuan',
  'report': 'icon-xinjianbaobiao',
  'board': 'icon-xinjianbaobiao',
  'business-group': 'icon-shujuyuan',
  'masterData': 'icon-layers',
  'data-integrate': 'icon-folder',
  'data-develop': 'icon-folder',
  'data-output': 'icon-folder',
  'firstDomain': 'icon-folder',
  'secondDomain': 'icon-folder',
  'region': 'icon-folder-filled',
  'hive2rdbmssync': 'icon-sync',
  'hive2rabbitMQ': 'icon-sync',
  'sftpsync': 'icon-sync',
  'dbsync': 'icon-sync',
  'hive2kafka': 'icon-sync',
  'apisync': 'icon-sync',
  'filesync': 'icon-sync',
  'sql': 'icon-sql',
  'shell': 'icon-shell',
  'flink-sql': 'icon-flink',
  'python': 'icon-python',
  'field-calculated': 'icon-shuzi',
  'field-group': 'icon-string',
  'field-association': 'icon-string',
  'field-number': 'icon-shuzi',
  'field-calendar': 'icon-shijian',
  'field-time': 'icon-shijian',
  'field-character': 'icon-string',
  'otherFolder': 'icon-folder',
  'otherDB': 'icon-model',
  'authSys': 'icon-xitong',
  'firstLevel': 'icon-baobiao',
  'schema': 'icon-table1',
  'thirdapi': 'icon-shujuyuan'
}

/**
 * 递归查询树节点
 */
export function findTreeNodeByDataId (list, dataId) {
  let targetNode
  _findNode(list, dataId)
  return targetNode

  function _findNode (list, dataId) {
    for (let i = 0; i < (list.length); i++) {
      if (list[i].dataId === dataId) {
        targetNode = list[i]
        // console.log(targetNode)
      }
      if (list[i].children && list[i].children.length > 0) {
        _findNode(list[i].children, dataId)
      }
    }
  }
}
/**
 * 递归查询树节点
 */
export function findTreeNodeById (list, id) {
  let targetNode
  _findNode(list, id)
  return targetNode

  function _findNode (list, id) {
    for (let i = 0; i < (list.length); i++) {
      if (list[i].id === id) {
        targetNode = list[i]
        // console.log(targetNode)
      }
      if (list[i].children && list[i].children.length > 0) {
        _findNode(list[i].children, id)
      }
    }
  }
}
